import axios from "axios";
// eslint-disable-next-line
export default {
  tabs: (navs_id) => {
    //  console.log(navs_id);
    return axios.get(`/api/tabs/getOne/${navs_id}`).then(({ data }) => {
      console.log("in",data);
      return data;
    });
  },
  changes: (_id) => {
    // console.log(_id);
    return axios
      .get(`/api/tabs/changeOne/${_id}`, {
        params: {
          _id,
        },
      })
      .then(({ data }) => {
        console.log(data);
        return data;
      });
  },
  changeItem: (
    { _id, name } // console.log(newData,typeof newData)
  ) => {
    return axios
      .put(`/api/tabs/change`, {
        _id,
        name,
      })
      .then(({ data }) => {
        return data;
      });
  },
  remove: async({_id}) => {
    console.log(_id);
    return axios
    .delete(`/api/tabs/remove`, {
     data:{_id} 
    })
    .then (({data}) => {
      return data;
    });
  },
  //获取商品类型
  getTabs: (navsId) =>
    axios
      .get(`/api/tabs/searchTabs`, { params: { navsId: navsId } })
      .then(({ data }) => {
        return data;
      }),
  //新增商品类型
  addTabs: ({ name, navsId }) =>
    axios
      .post(`/api/tabs/addTab`, {
        name,
        navsId,
      })
      .then(({ data }) => {
        return data;
      }),
};
